<template>
    <div>
        <Row :gutter="10">
            <Col>
                <Card>
                    <Row class="live_wrapper clearfix">
                        <Input v-model="filter.phone" @on-search="search" search enter-button="查询" placeholder="请输入手机号"
                               style="width:290px; margin-right: 10px;float: right;top:0;font-size: 14px;"/>
                    </Row>
                    <Row class="margin-top-10 table_pattern table_pattern2">
                        <Table :loading="loading" :columns="columns" :data="list"></Table>
                    </Row>
                    <Row class="margin-top-10">
                        <Page :total="pagenation.totalPage" :page-size="pagenation.perPage"
                              :current="pagenation.currentPage" show-elevator show-total @on-change="change"></Page>
                    </Row>
                </Card>
            </Col>
        </Row>
    </div>
</template>
<script>
    import config from '@/config'
    import { repairUserList} from '@/api/main'
    export default {
        data() {
            return {
                pagenation: {},
                columns: [
                    {
                        key: 'phone',
                        title: '手机号',
                        align: 'center',
                        render: (h, params) => {
                            return h('strong', params.row.phone)
                        },
                    },
                    {
                        key: 'name',
                        title: '姓名',
                        align: 'center',
                        render: (h, params) => {
                            return h('strong', params.row.name)
                        },
                    },
                    {
                        key: 'created_time',
                        title: '注册时间',
                        align: 'center',
                        render: (h, params) => {
                            return h('strong', params.row.created_time)
                        },
                    },
                ],
                list: [],
                loading: true,
                filter: {
                    page: 0,
                    phone: '',
                    repair_id: this.$route.params.rid
                },
            }
        },
        methods: {
            change: function(page) {
                this.loading = true
                this.filter.page = page-1
                this.init()
            },
            search: function () {
                this.filter.page = 0
                this.init()
            },
            init () {
                repairUserList(this.filter).then(res => {
                    if (res.code == 0) {
                        this.list = res.data
                        this.loading = false
                        this.pagenation.currentPage = parseInt(res.currentPage) + 1
                        this.pagenation.totalPage = parseInt(res.totalPage)
                        this.pagenation.perPage = parseInt(res.perPage)
                    }
                })
            }
        },
        mounted() {
            this.init();
        }
    }
</script>
